.class public Lde/dealdoktor/app/adapter/CategoriesListAdapter;
.super Landroid/widget/BaseAdapter;
.source "CategoriesListAdapter.java"

# interfaces
.implements Landroid/widget/SectionIndexer;


# instance fields
.field private a:Landroid/app/Activity;

.field private alphaIndexer:Ljava/util/HashMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/HashMap",
            "<",
            "Ljava/lang/String;",
            "Ljava/lang/Integer;",
            ">;"
        }
    .end annotation
.end field

.field private sections:[Ljava/lang/String;


# direct methods
.method public constructor <init>(Landroid/app/Activity;)V
    .locals 1
    .parameter "a"

    .prologue
    .line 28
    invoke-direct {p0}, Landroid/widget/BaseAdapter;-><init>()V

    .line 30
    sget-object v0, Lde/dealdoktor/app/App;->categories:Ljava/util/ArrayList;

    if-nez v0, :cond_0

    .line 31
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    sput-object v0, Lde/dealdoktor/app/App;->categories:Ljava/util/ArrayList;

    .line 34
    :cond_0
    iput-object p1, p0, Lde/dealdoktor/app/adapter/CategoriesListAdapter;->a:Landroid/app/Activity;

    .line 35
    invoke-direct {p0}, Lde/dealdoktor/app/adapter/CategoriesListAdapter;->createSections()V

    .line 36
    return-void
.end method

.method private createSections()V
    .locals 9

    .prologue
    .line 99
    new-instance v6, Ljava/util/HashMap;

    invoke-direct {v6}, Ljava/util/HashMap;-><init>()V

    iput-object v6, p0, Lde/dealdoktor/app/adapter/CategoriesListAdapter;->alphaIndexer:Ljava/util/HashMap;

    .line 100
    sget-object v6, Lde/dealdoktor/app/App;->categories:Ljava/util/ArrayList;

    invoke-virtual {v6}, Ljava/util/ArrayList;->size()I

    move-result v5

    .line 102
    .local v5, size:I
    add-int/lit8 v2, v5, -0x1

    .local v2, i:I
    :goto_0
    if-gez v2, :cond_0

    .line 115
    iget-object v6, p0, Lde/dealdoktor/app/adapter/CategoriesListAdapter;->alphaIndexer:Ljava/util/HashMap;

    invoke-virtual {v6}, Ljava/util/HashMap;->keySet()Ljava/util/Set;

    move-result-object v3

    .line 118
    .local v3, sectionLetters:Ljava/util/Set;,"Ljava/util/Set<Ljava/lang/String;>;"
    new-instance v4, Ljava/util/ArrayList;

    invoke-direct {v4, v3}, Ljava/util/ArrayList;-><init>(Ljava/util/Collection;)V

    .line 120
    .local v4, sectionList:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Ljava/lang/String;>;"
    invoke-static {v4}, Ljava/util/Collections;->sort(Ljava/util/List;)V

    .line 122
    invoke-virtual {v4}, Ljava/util/ArrayList;->size()I

    move-result v6

    new-array v6, v6, [Ljava/lang/String;

    iput-object v6, p0, Lde/dealdoktor/app/adapter/CategoriesListAdapter;->sections:[Ljava/lang/String;

    .line 124
    iget-object v6, p0, Lde/dealdoktor/app/adapter/CategoriesListAdapter;->sections:[Ljava/lang/String;

    invoke-virtual {v4, v6}, Ljava/util/ArrayList;->toArray([Ljava/lang/Object;)[Ljava/lang/Object;

    .line 125
    return-void

    .line 103
    .end local v3           #sectionLetters:Ljava/util/Set;,"Ljava/util/Set<Ljava/lang/String;>;"
    .end local v4           #sectionList:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Ljava/lang/String;>;"
    :cond_0
    sget-object v6, Lde/dealdoktor/app/App;->categories:Ljava/util/ArrayList;

    invoke-virtual {v6, v2}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lde/dealdoktor/app/data/CategoriesDAO;

    .line 106
    .local v0, c:Lde/dealdoktor/app/data/CategoriesDAO;
    iget-object v6, v0, Lde/dealdoktor/app/data/CategoriesDAO;->title:Ljava/lang/String;

    const/4 v7, 0x0

    const/4 v8, 0x1

    invoke-virtual {v6, v7, v8}, Ljava/lang/String;->substring(II)Ljava/lang/String;

    move-result-object v1

    .line 109
    .local v1, ch:Ljava/lang/String;
    invoke-virtual {v1}, Ljava/lang/String;->toUpperCase()Ljava/lang/String;

    move-result-object v1

    .line 112
    iget-object v6, p0, Lde/dealdoktor/app/adapter/CategoriesListAdapter;->alphaIndexer:Ljava/util/HashMap;

    invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v7

    invoke-virtual {v6, v1, v7}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 102
    add-int/lit8 v2, v2, -0x1

    goto :goto_0
.end method


# virtual methods
.method public getCount()I
    .locals 1

    .prologue
    .line 40
    sget-object v0, Lde/dealdoktor/app/App;->categories:Ljava/util/ArrayList;

    invoke-virtual {v0}, Ljava/util/ArrayList;->size()I

    move-result v0

    return v0
.end method

.method public getItem(I)Lde/dealdoktor/app/data/CategoriesDAO;
    .locals 1
    .parameter "position"

    .prologue
    .line 45
    sget-object v0, Lde/dealdoktor/app/App;->categories:Ljava/util/ArrayList;

    invoke-virtual {v0, p1}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lde/dealdoktor/app/data/CategoriesDAO;

    return-object v0
.end method

.method public bridge synthetic getItem(I)Ljava/lang/Object;
    .locals 1
    .parameter

    .prologue
    .line 1
    invoke-virtual {p0, p1}, Lde/dealdoktor/app/adapter/CategoriesListAdapter;->getItem(I)Lde/dealdoktor/app/data/CategoriesDAO;

    move-result-object v0

    return-object v0
.end method

.method public getItemId(I)J
    .locals 2
    .parameter "position"

    .prologue
    .line 50
    int-to-long v0, p1

    return-wide v0
.end method

.method public getPositionForSection(I)I
    .locals 2
    .parameter "section"

    .prologue
    .line 78
    iget-object v0, p0, Lde/dealdoktor/app/adapter/CategoriesListAdapter;->alphaIndexer:Ljava/util/HashMap;

    iget-object v1, p0, Lde/dealdoktor/app/adapter/CategoriesListAdapter;->sections:[Ljava/lang/String;

    aget-object v1, v1, p1

    invoke-virtual {v0, v1}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/Integer;

    invoke-virtual {v0}, Ljava/lang/Integer;->intValue()I

    move-result v0

    return v0
.end method

.method public getSectionForPosition(I)I
    .locals 6
    .parameter "position"

    .prologue
    const/4 v3, 0x1

    .line 83
    sget-object v4, Lde/dealdoktor/app/App;->categories:Ljava/util/ArrayList;

    invoke-virtual {v4, p1}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lde/dealdoktor/app/data/CategoriesDAO;

    .line 84
    .local v0, c:Lde/dealdoktor/app/data/CategoriesDAO;
    iget-object v4, v0, Lde/dealdoktor/app/data/CategoriesDAO;->title:Ljava/lang/String;

    const/4 v5, 0x0

    invoke-virtual {v4, v5, v3}, Ljava/lang/String;->substring(II)Ljava/lang/String;

    move-result-object v1

    .line 85
    .local v1, ch:Ljava/lang/String;
    const/4 v2, 0x0

    .local v2, i:I
    :goto_0
    iget-object v4, p0, Lde/dealdoktor/app/adapter/CategoriesListAdapter;->sections:[Ljava/lang/String;

    array-length v4, v4

    if-lt v2, v4, :cond_1

    move v2, v3

    .line 90
    .end local v2           #i:I
    :cond_0
    return v2

    .line 86
    .restart local v2       #i:I
    :cond_1
    iget-object v4, p0, Lde/dealdoktor/app/adapter/CategoriesListAdapter;->sections:[Ljava/lang/String;

    aget-object v4, v4, v2

    invoke-virtual {v4, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v4

    if-nez v4, :cond_0

    .line 85
    add-int/lit8 v2, v2, 0x1

    goto :goto_0
.end method

.method public getSections()[Ljava/lang/Object;
    .locals 1

    .prologue
    .line 95
    iget-object v0, p0, Lde/dealdoktor/app/adapter/CategoriesListAdapter;->sections:[Ljava/lang/String;

    return-object v0
.end method

.method public getView(ILandroid/view/View;Landroid/view/ViewGroup;)Landroid/view/View;
    .locals 6
    .parameter "position"
    .parameter "convertView"
    .parameter "parent"

    .prologue
    .line 55
    invoke-virtual {p0, p1}, Lde/dealdoktor/app/adapter/CategoriesListAdapter;->getItem(I)Lde/dealdoktor/app/data/CategoriesDAO;

    move-result-object v1

    .line 57
    .local v1, item:Lde/dealdoktor/app/data/CategoriesDAO;
    move-object v2, p2

    .line 58
    .local v2, rowView:Landroid/view/View;
    iget-object v4, p0, Lde/dealdoktor/app/adapter/CategoriesListAdapter;->a:Landroid/app/Activity;

    invoke-virtual {v4}, Landroid/app/Activity;->getApplicationContext()Landroid/content/Context;

    move-result-object v4

    .line 59
    const-string v5, "layout_inflater"

    .line 58
    invoke-virtual {v4, v5}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/view/LayoutInflater;

    .line 60
    .local v0, infl:Landroid/view/LayoutInflater;
    if-nez v2, :cond_0

    .line 61
    const v4, 0x7f030010

    const/4 v5, 0x0

    invoke-virtual {v0, v4, v5}, Landroid/view/LayoutInflater;->inflate(ILandroid/view/ViewGroup;)Landroid/view/View;

    move-result-object v2

    .line 66
    :cond_0
    const v4, 0x1020014

    invoke-virtual {v2, v4}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v3

    check-cast v3, Landroid/widget/CheckedTextView;

    .line 70
    .local v3, title:Landroid/widget/CheckedTextView;
    iget-object v4, v1, Lde/dealdoktor/app/data/CategoriesDAO;->title:Ljava/lang/String;

    invoke-static {v4}, Landroid/text/Html;->fromHtml(Ljava/lang/String;)Landroid/text/Spanned;

    move-result-object v4

    invoke-virtual {v3, v4}, Landroid/widget/CheckedTextView;->setText(Ljava/lang/CharSequence;)V

    .line 73
    return-object v2
.end method
